import request from '@/utils/request'

interface ApiResponse<T = any> {
  code: number
  msg: string
  data: T
  timestamp?: number
  profile_type?: 'admin' | 'lawyer' // 添加profile_type字段
}

interface PaginationData<T> {
  list: T[]
  total: number
  page?: number
  limit?: number
}

// 员工档案相关API
export const archivesApi = {
  // 获取员工档案列表
  getList: (params: any): Promise<ApiResponse<PaginationData<any>>> => {
    return request({
      url: '/api/user/archives/list',
      method: 'get',
      params,
    })
  },

  // 获取员工档案详情
  getDetail: (id: number): Promise<ApiResponse<any>> => {
    return request({
      url: '/api/user/archives/view',
      method: 'get',
      params: { id },
    })
  },

  // 新增员工档案
  add: (data: any): Promise<ApiResponse> => {
    return request({
      url: '/api/user/archives/add',
      method: 'post',
      data,
    })
  },

  // 编辑员工档案
  edit: (data: any): Promise<ApiResponse> => {
    return request({
      url: '/api/user/archives/edit',
      method: 'put',
      data,
    })
  },

  // 删除员工档案
  delete: (id: number): Promise<ApiResponse> => {
    return request({
      url: '/api/user/archives/del',
      method: 'delete',
      params: { id },
    })
  },
}

export default archivesApi
